<template>
    <div class="wdxc">
        <h2>我的相册</h2>
        <ul>
            <template v-if="photos.id === undefined">
                还没有相册哦~
            </template>
            <template v-else>
                <li v-for="(p,index) in photos" :key="index"><a :href="p.p_url"><img :src="p.p_img_url"></a></li>
            </template>
        </ul>
    </div>
</template>

<script>
    import {getPhoto} from "../service/getData";

    export default {
        name: "photo",
        data() {
            return {
                photos: [
                    {
                        id: 1,
                        p_article_id: 1,
                        p_id: 1,
                        p_img_url: "images/7.jpg",
                        p_name: "阳光",
                        p_url: 9587
                    }
                ],
                total: 1,
                currvals: 1,
            }
        },
        methods: {
            get_photo: function () {
                getPhoto(this.currvals).then((res) => {
                    this.photos = res.data.content;
                    this.total = res.data.totalPages;
                })
            }
        }, mounted() {
            this.get_photo();
        }
    }
</script>
